<template>
	<div class="imgviewer" v-show="show">
		<viewer :images="imgArray" @inited="inited" inline ref="myviewer">
			<img v-for="(src,index) in imgArray" :src="src" :key="index" width="300">
		</viewer>
	</div>
</template>
<style scoped>
</style>
<script>
	export default {
		name: "imgViewer",
		props: {
			imglist: {
				default: [],
			},
			imgkey: {
				default: null
			}
		},
		data() {
			return {
				dateTime:"",
				show: false
			};
		},
		computed: {
			imgArray() {
				try {
					if (this.imgkey) {
						return this.imglist.map(i => i[this.imgkey]);
					} else {
						return this.imglist.map(i => i);
					}
				} catch (error) {
					return [];
				}
			}
		},
		methods: {
			inited(viewer) {
				this.$viewer = viewer
			},
			showImg(index = 0) {
				if (this.imgArray.length > 0) {
					this.$viewer.view(index);
					this.$viewer.show();
				}
			},
			mounted() {}
		}
	};
</script>